<?php 
/**
 * 用户注册模型
 */
class RegisterModel extends Model{
    public $table = 'user';
    
    public $auto = array();
    
    public $validate = array(
		array('username','nonull','用户名不能为空',2,3),
		array('password_reg1','nonull','密码不能为空',2,3),
		array('password_reg1','confirm:password_reg2','两次密码不一致',2,3),
		array('angree','nonull','请接收卷皮网协议',2,3),
	);
    
    public function vRegister(){
		//自动验证判断
        if(!$this->create()) return false;
		//判断用户名是否存在
		$username = htmlspecialchars($_POST['username']);
		$userInfo = $this->where("username='{$username}'")->find();
		if($userInfo){
			$this->error = '用户名已存在';
			return false;
		}
		
		//如果全部通过则压入数组
		$this->data['username'] = $username;
		$this->data['mobile'] = $username;
		$this->data['password'] = md5($_POST['password_reg1']);
		return $this->add();
    }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 }




 
 
 
 